package com.eliteams.quick4j.web.interceptors.helper;

import com.alibaba.fastjson.JSONObject;
import com.eliteams.quick4j.core.entity.OApiException;
import com.eliteams.quick4j.core.entity.OApiResultException;
import com.eliteams.quick4j.web.Env;

public class OpenAccountHelper {

	public static String getSnsToken() throws OApiException {
		String url = "https://oapi.dingtalk.com/sns/gettoken?appid=" + Env.CORP_ID + "&appsecret=" + Env.SSO_Secret;
		JSONObject response = HttpHelper.httpGet(url);
		String ssoToken;
		if (response.containsKey("access_token")) {
			ssoToken = response.getString("access_token");
		} else {
			throw new OApiResultException("Sso_token");
		}
		return ssoToken;

	}
}
